/**
 * 审核统计
 * - 使用自定义封装组件，简化代码，统一管理。
 * - 2025-07-12 13:14:21 tzj
 * */

import BaseComponent from "../../components/BaseComponent";
import {mrhzApi} from "../../services/basic";
import Dictionary from "../../services/dictionary";

// 要显示的form表单
const formItemList =
    [
        "companies",
        {name: "chooseDateRange", label: '到店/成交日期'}
    ];
// 显示的按钮
const buttons = ["query", "export",];

const jzlRender = (_, record) => {
    return Number(record.zjz) ? (Number(record.yjz) * 100 / Number(record.zjz)).toFixed(2) : 0
}
// 表格列信息
const columns = [
    {
        title: '公司名称',
        dataIndex: 'gsmc',
        key: 'gsmc',
        width: "30%",
        sumName: "合计",
    },
    {
        title: '总校准',
        dataIndex: 'zjz',
        sorter: true,
    },
    {
        title: '已校准',
        dataIndex: 'yjz',
        sorter: true,
    },
    {
        title: '未校准',
        dataIndex: 'wjz',
        sorter: true,
    },
    {
        title: '校准率(%)',
        dataIndex: 'jzl',
        render: jzlRender,
        sorter: true,
        numFmt: "0.00%",
        formula: "=IFERROR({{yjz}}/{{zjz}}, 0)",
    },
]

class Shtj extends BaseComponent {
    constructor(props) {
        super(props);
        this.state = {
            ...this.state,
            formItemList,
            buttons,
            // columns,
            filename: "审核统计表",
            queryAll: true,
            sumRow: true,
        }
        this.columns = columns;
        this.queryApi = mrhzApi.getPagesh;
        this.hasLzModal = true;
    }

    onRowDoubleClick = (record) => {
        const params = {
            ...this.form.dataForm,
            yybm: record.yybm,
        }
        const config = {
            queryApi: mrhzApi.selectPagecj,
            columns: Dictionary.dealColumns,
            tableTitle: "审核详情",
            // width: 1200
        }
        this.lzModalRef.open(params, config);
    }
}

export default Shtj;